﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="Problem13.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation.  All rights reserved. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>
//   Defines the Problem13 type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace EulerProblemsCSharp.Problems
{
    using System;
    using System.Globalization;
    using System.IO;
    using System.Linq;

    /// <summary>
    /// Problem 13.
    /// </summary>
    public class Problem13 : ProblemBase
    {
        /// <summary>
        /// Gets Number.
        /// </summary>
        /// <value>
        /// The number.
        /// </value>
        public override int Number
        {
            get
            {
                return 13;
            }
        }

        /// <summary>
        /// Gets Description.
        /// </summary>
        /// <value>
        /// The description.
        /// </value>
        public override string Description
        {
            get
            {
                return "Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.";
            }
        }

        /// <summary>
        /// Solves the problem.
        /// </summary>
        /// <returns>
        /// Solution to the problem.
        /// </returns>
        public override object Solve()
        {
            var query = from line in File.ReadAllLines("problem13.txt")
                        select Convert.ToInt64(line.Substring(0, 11), CultureInfo.InvariantCulture);

            var answer = query.Sum().ToString(CultureInfo.InvariantCulture).Substring(0, 10);
            
            return answer;
        }
    }
}